package com.project.lk.nurseapp.nurse.doctorapply;

import android.content.Intent;
import android.view.View;
import android.widget.ImageView;
import android.widget.RadioButton;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.project.lk.nurseapp.R;
import com.project.lk.nurseapp.base.BaseActivity;
import com.project.lk.nurseapp.base.UrlContants;
import com.project.lk.nurseapp.nurse.doctorapply.model.ApplyBean;
import com.project.lk.nurseapp.nurse.doctorapply.model.DoctorApplyInfoBean;
import com.project.lk.nurseapp.nurse.doctorapply.model.DoctorItemBean;
import com.project.lk.nurseapp.ticket.model.ITicketBeanInfo;
import com.project.lk.nurseapp.ticket.model.TicketItemBean;
import com.project.lk.nurseapp.nurse.doctorapply.presenter.DoctorApplyPresenter;
import com.project.lk.nurseapp.nurse.doctorapply.presenter.IDoctorApplyView;
import com.project.lk.nurseapp.ticket.TicketActivity;
import com.project.lk.nurseapp.utils.AppManager;

import org.greenrobot.eventbus.EventBus;
import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.io.Serializable;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;
/**
 * 功能介绍：
 * 项目名：
 * 模块名称：
 * 作者：LK
 * 日期：2018/1/9
 * 修改日期：
 */
public class PayDoctorActivity extends BaseActivity implements IDoctorApplyView{


    @BindView(R.id.icon_iv)
    ImageView iconIv;
    @BindView(R.id.nickname_tv)
    TextView nicknameTv;
    @BindView(R.id.post_tv)
    TextView postTv;
    @BindView(R.id.context_tv)
    TextView contextTv;
    @BindView(R.id.all_money_tv)
    TextView allMoneyTv;
    @BindView(R.id.coupon_text)
    TextView couponText;
    @BindView(R.id.need_apply_tv)
    TextView needApplyTv;
    @BindView(R.id.wx_apply_rb)
    RadioButton wxApplyRb;
    @BindView(R.id.aliba_apply_rb)
    RadioButton alibaApplyRb;
    private DoctorApplyPresenter presenter;
    private String userConponId="";
    private DoctorItemBean doctorItemBean;

    @Override
    protected void initData() {
        if (!EventBus.getDefault().isRegistered(this)) {
            EventBus.getDefault().register(this);
        }
        doctorItemBean = (DoctorItemBean) getIntent().getSerializableExtra("pay");
        presenter = new DoctorApplyPresenter(this);

    }

    @Override
    protected void initView() {
        String nickname = doctorItemBean.getNickname();
        String consultationFee = doctorItemBean.getConsultationFee();
        String headImg = doctorItemBean.getHeadImg();
        String skilful = doctorItemBean.getSkilful();
        String profiles = doctorItemBean.getProfiles();
        String job = doctorItemBean.getJob();
        Glide.with(this).load(headImg).error(R.drawable.moren)
                .placeholder(R.drawable.moren).into(iconIv);
        contextTv.setText(skilful);
        postTv.setText(job);
        nicknameTv.setText(nickname);
        needApplyTv.setText(consultationFee);
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_pay_doctor;
    }


    @Subscribe(threadMode = ThreadMode.MAIN)
    public void getTicketData(ITicketBeanInfo info){
        TicketItemBean data = info.getData();
        String couponName = data.getCouponName();
        couponText.setText(couponName);
        userConponId = data.getId();
    }
    @OnClick({R.id.back, R.id.coupon_layout, R.id.wx_apply_rb, R.id.aliba_apply_rb, R.id.apply_but})
    public void onViewClicked(View view) {
        switch (view.getId()) {
            case R.id.back:
                AppManager.getAppManager().finishActivity();
                break;
            case R.id.coupon_layout: //选择优惠券
                startActivity(new Intent(this,TicketActivity.class)
                .putExtra("ticket","pay"));
                break;
            case R.id.wx_apply_rb: //选择微信支付

                break;
            case R.id.aliba_apply_rb: //选择支付宝支付

                break;
            case R.id.apply_but: //支付

                break;
        }
    }


    @Override
    public void applySuccess() {

    }

    @Override
    public void applyFail() {

    }

    @Override
    public void orderApplySuccess() {

    }

    @Override
    public void orderApplyFail() {

    }

    @Override
    public void applyTicketSuccess() {  //抵用券刚好抵用了支付费用

    }


    @Override
    protected void onDestroy() {
        super.onDestroy();
        EventBus.getDefault().unregister(this);
    }
}
